import java.io.*;
public class factory{
    public static void main(String[] args){
        shapeFactory shapefactory = new shapeFactory();
        shape shape1 = shapefactory.getShape("circle");
        shape1.draw();
        shape shape2 = shapefactory.getShape("square");
        shape shape3 = shapefactory.getShape("rectangle");
        shape2.draw();
        shape3.draw();
            
    }
}
interface shape{
    public void draw();
}
class Circle implements shape{
    public void draw()
    {
        System.out.println("inside circle");
    }
}
class Square implements shape{
    public void draw()
    {
        System.out.println("inside Square");
    }
}
class Rectangle implements shape{
    public void draw()
    {
        System.out.println("inside Rectangle");
    }
}
class shapeFactory{
    shape getShape(String shapeType)
    {
        if(shapeType == null)
        {
            return null;
        }
        if(shapeType == "circle")
        {
            return new Circle();
        }
        if(shapeType == "square")
        {
            return new Square();
        }
        if(shapeType == "rectangle")
        {
            return new Rectangle();
        }
        return null;
    }
}
